package com.wjerp.tplus.server.common.exception;


import com.wjerp.tplus.server.common.constant.ErrorDetail;

import java.text.MessageFormat;


public class ServiceException extends Exception {
	/**
	 *
	 */
	private static final Long serialVersionUID = 1L;

	String errorMsg;
	String errorCode;

	public ServiceException(){
		super();
	}

	public ServiceException(String errorCode, String errorMsg){
		super();

		this.errorCode = errorCode;
		this.errorMsg = errorMsg;

	}

	public ServiceException(String messsage){
		super();
		this.errorMsg = messsage;
	}

	public ServiceException(ErrorDetail e){
		super();

		this.errorCode = e.getErrorCode();
		this.errorMsg = e.getErrorMsg();
	}

	public ServiceException(ErrorDetail e, String[] params){
		super();
		this.errorCode = e.getErrorCode();
		String errorMsg = e.getErrorMsg();
		this.errorMsg = MessageFormat.format(errorMsg, params);
	}

	public String getErrorMsg(){
		return errorMsg;
	}
	
	public String getErrorCode(){
		return errorCode;
	}
	
}
